]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
combo-box-menu-item: Propagate pseudo classes to the combo menu
authorFlorian Müllner <fmuellner@gnome.org>
Wed, 26 Oct 2011 17:24:36 +0000 (19:24 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Tue, 15 Nov 2011 12:54:29 +0000 (13:54 +0100)
ComboBoxMenuItems use ClutterClones to reconstruct the active item
in the associated ComboMenu, so pseudo class changes due to state
changes of the ComboBoxMenuItem don't have the intended effect
(since the actual style information is taken from the associated
ComboBoxMenu item).
As a fix, propagate relevant pseudo class changes to the active
ComboBoxMenu item.

https://bugzilla.gnome.org/show_bug.cgi?id=662799

js/ui/popupMenu.js

index 0c047487fcb1efea60856731794b90ab795a9f1f..6aee9f4191de743c276d3b3870b094a61e057198 100644 (file)
@@ -108,14 +108,16 @@ PopupBaseMenuItem.prototype = {
         this.emit('activate', event);
     },
 
-    setActive: function (active) {
+    setActive: function (active, params) {
         let activeChanged = active != this.active;
+        params = Params.parse (params, { grabKeyboard: true });
 
         if (activeChanged) {
             this.active = active;
             if (active) {
                 this.actor.add_style_pseudo_class('active');
-                this.actor.grab_key_focus();
+                if (params.grabKeyboard)
+                    this.actor.grab_key_focus();
             } else
                 this.actor.remove_style_pseudo_class('active');
             this.emit('active-changed', active);
@@ -1522,6 +1524,22 @@ PopupComboMenu.prototype = {
     },
 
     _onSourceActorStyleChanged: function() {
+        // PopupComboBoxMenuItem clones the active item's actors
+        // to work with arbitrary items in the menu; this means
+        // that we need to propagate some style information and
+        // enforce style updates even when the menu is closed
+        let activeItem = this._getMenuItems()[this._activeItemPos];
+        if (this.sourceActor.has_style_pseudo_class('insensitive'))
+            activeItem.actor.add_style_pseudo_class('insensitive');
+        else
+            activeItem.actor.remove_style_pseudo_class('insensitive');
+
+        // To propagate the :active style, we need to make sure that the
+        // internal state of the PopupComboMenu is updated as well, but
+        // we must not move the keyboard grab
+        activeItem.setActive(this.sourceActor.has_style_pseudo_class('active'),
+                             { grabKeyboard: false });
+
         _ensureStyle(this.actor);
     },